<template>
  <div class="top">
    <div class="left">
      <span class="left_btn" @click="goHome">首页</span>
    </div>
    <div class="center">
      <div class="title">小何很牛可视化大数据平台</div>
    </div>
    <div class="right">
      <span class="right_btn">统计报告</span>
      <span class="right_time">当前时间:{{ time }}</span>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted, onBeforeUnmount } from "vue";
// @ts-expect-error
import moment from "moment";
// 获取路由器对象
import { useRouter } from "vue-router";
let $router = useRouter();
// 存储当前时间
let time = ref(moment().format(" YYYY年MM月DD日 hh:mm:ss"));
let timer = ref();
// 点击回到首页
const goHome = () => {
  $router.push("./home");
};
onMounted(() => {
  timer.value = setInterval(() => {
    time.value = moment().format(" YYYY年MM月DD日 hh:mm:ss");
  }, 1000);
});
onBeforeUnmount(() => {
  clearInterval(timer.value);
});
</script>

<style scoped lang="scss">
.top {
  width: 100%;
  height: 40px;
  display: flex;
  color: #29fcff;

  .right,
  .left {
    flex: 1;
    background: url(../../../../assets/images/screen/dataScreen-header-left-bg.png)
      no-repeat;
    background-size: cover;
    display: flex;
    justify-content: end;

    .right_btn,
    .left_btn {
      width: 120px;
      height: 40px;
      background: url(../../../../assets/images/screen/dataScreen-header-btn-bg-l.png)
        no-repeat;
      background-size: 100% 100%;
      text-align: center;
      line-height: 40px;
      cursor: pointer;
    }

    .right_btn:hover,
    .left_btn:hover {
      color: #0fa2a5;
    }
  }

  .right {
    background: url(../../../../assets/images/screen/dataScreen-header-right-bg.png)
      no-repeat;
    justify-content: space-between;
    align-items: center;

    .right_btn {
      background: url(../../../../assets/images/screen/dataScreen-header-btn-bg-r.png)
        no-repeat;
      background-size: 100% 100%;
    }

    .right_time {
      width: 100%;
      text-align: center;
    }
  }

  .center {
    flex: 2;

    .title {
      width: 100%;
      height: 74px;
      background: url(../../../../assets/images/screen/dataScreen-header-center-bg.png)
        no-repeat;
      background-size: 100% 100%;
      text-align: center;
      line-height: 74px;
      font-size: 28px;
    }
  }
}
</style>
